//
//  SLSpecialOffersCell.m
//  StarLight
//
//  Created by apple on 16/8/12.
//  Copyright © 2016年 Duke.Wu. All rights reserved.
//

#import "SLSpecialOffersCell.h"

@interface SLSpecialOffersCell ()

@property (nonatomic ,strong) UIImageView *bgImg;
@property (nonatomic ,strong) UILabel *titleName;
@property (nonatomic ,strong) UILabel *content;
@property (nonatomic ,strong) UILabel *info;
@property (nonatomic ,strong) UIImageView *inImg;

@end

@implementation SLSpecialOffersCell

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self addUI];
    }
    return self;
}

- (void)cellForData:(SLSpecialOffersModel *)model
{
    [self.bgImg sd_setImageWithURL:[NSURL URLWithString:model.imageUrl] placeholderImage:IMG(@"bg") options:SDWebImageRetryFailed | SDWebImageLowPriority];
    self.content.text = model.desc;
    self.titleName.text = model.title;
}

- (void)addUI{
    [self addSubview:self.bgImg];
    [self addSubview:self.titleName];
    [self addSubview:self.content];
    [self addSubview:self.info];
    [self addSubview:self.inImg];
    
    [self.bgImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(self).with.offset(4);
        make.right.equalTo(self).with.offset(-4);
        make.height.mas_equalTo(120 * MIX_H);
    }];
    [self.titleName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bgImg.mas_bottom).with.offset(9);
        make.left.equalTo(self).with.offset(13);
        make.right.equalTo(self).with.offset(-13);
    }];
    [self.content mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleName.mas_bottom).with.offset(13);
        make.left.equalTo(self.titleName);
        make.right.equalTo(self).with.offset(-29);
    }];
    [self.inImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).with.offset(-7);
        make.bottom.equalTo(self).with.offset(-8);
    }];
    [self.info mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.inImg);
        make.right.equalTo(self.inImg.mas_left).with.offset(-14);
    }];
}
- (UIImageView *)bgImg{
    if (!_bgImg) {
        _bgImg = [UIImageView new];
        _bgImg.image = IMG(@"bg");
    }
    return _bgImg;
}
- (UILabel *)titleName{
    if (!_titleName) {
        _titleName = [UILabel new];
        _titleName.font = sFont(15);
        _titleName.textColor = RGBCOLOR(38, 38, 38);
        _titleName.text = @"大连直达俄罗斯班列开行";
    }
    return _titleName;
}
- (UILabel *)content{
    if (!_content) {
        _content = [UILabel new];
        _content.font = sFont(13);
        _content.textColor = RGBCOLOR(153, 153, 153);
        _content.numberOfLines = 2;
        _content.text = @"今天上午，满载着韩国三星电子设备的国际集装箱班列从大连大窑湾";
    }
    return _content;
}
- (UILabel *)info{
    if (!_info) {
        _info = [UILabel new];
        _info.font = sFont(10);
        _info.textColor = RGBCOLOR(253, 207, 0);
        _info.text = @"更多详情";
    }
    return _info;
}
- (UIImageView *)inImg{
    if (!_inImg) {
        _inImg = [UIImageView new];
        _inImg.image = IMG(@"ic_arrow_gray");
    }
    return _inImg;
}

@end
